package com.coca1cole.auth.domain.service.impl;

import com.coca1cole.auth.common.enums.IsDeletedFlagEnum;
import com.coca1cole.auth.domain.convert.AuthUserRoleBOConverter;
import com.coca1cole.auth.domain.entity.AuthUserRoleBO;
import com.coca1cole.auth.domain.service.AuthUserRoleDomainService;
import com.coca1cole.auth.infra.basic.entity.AuthUserRole;
import com.coca1cole.auth.infra.basic.service.AuthUserRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 *  领域service实现了
 *
 * @author coca1cole
 * @since 2024-01-22 18:32:46
 */
@Service
@Slf4j
public class AuthUserRoleDomainServiceImpl implements AuthUserRoleDomainService {

    @Resource
    private AuthUserRoleService authUserRoleService;

    @Override
    public Boolean add(AuthUserRoleBO authUserRoleBO) {
        AuthUserRole authUserRole =AuthUserRoleBOConverter.INSTANCE.convertBOToEntity(authUserRoleBO);
        authUserRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        return authUserRoleService.insert(authUserRole) > 0;
    }

    @Override
    public Boolean update(AuthUserRoleBO authUserRoleBO) {
        AuthUserRole authUserRole =AuthUserRoleBOConverter.INSTANCE.convertBOToEntity(authUserRoleBO);
        return authUserRoleService.update(authUserRole) > 0;
    }

    @Override
    public Boolean delete(AuthUserRoleBO authUserRoleBO) {
        AuthUserRole authUserRole =new AuthUserRole();
        authUserRole.setId(authUserRoleBO.getId());
        authUserRole.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        return authUserRoleService.update(authUserRole) > 0;
    }

}
